package com.yantong.controller.web;

import com.yantong.pojo.WebAddress;
import com.yantong.result.ResultVo;
import com.yantong.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * 官网接口
 */
@Controller
@RequestMapping("/web")
public class WebController {

    @Autowired
    private AddressService addressService;

    /**
     * 联系我们
     * @author
     * @date
     */
    @RequestMapping("/contact")
    @ResponseBody
    public ResultVo contact(String address, String name, String phone) {
        WebAddress webAddress = new WebAddress();
        webAddress.setAddress(address);
        webAddress.setName(name);
        webAddress.setPhone(phone);
        webAddress.setCreateTime(new Date());
        webAddress.setType(0);

        ResultVo resultVo = new ResultVo();
        if(addressService.saveWebAddress(webAddress)>0){
            resultVo.put("success", true);
            return resultVo;
        }
        return ResultVo.error();
    }
}
